//
//  GridCell.swift
//  A-star
//
//  Created by xukai on 2018/1/8.
//  Copyright © 2018年 xukai. All rights reserved.
//

import UIKit

protocol GridCellDelegate : NSObjectProtocol
{
    func gridCellClisk(cell : GridCell)
}

class GridCell: UIView {

    enum CellStyle {
        
        case Default // 默认
        case Start // 起点
        case End // 终点
        case Hinder // 障碍

    }
    
    weak var delegate : GridCellDelegate?
    
    public var p = CGPoint(x: 0, y: 0)
    public var cellStyle = CellStyle.Default
    public var isLook = false
    public var prentCell : GridCell?
    public var G = 0
    public var H = 0
    public var F : Int
    {
        get{
            return G + H
        }
    }
    
    public var lab = UILabel()
    
    private var bgColor = UIColor.orange
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.prentCell = nil
        self.backgroundColor = bgColor;

        // 添加手势
        let tap = UITapGestureRecognizer(target: self, action: #selector(GridCell.cellClick))
        self.addGestureRecognizer(tap)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func cellClick() {
        if(delegate != nil)
        {
            delegate?.gridCellClisk(cell: self)
        }
    }
    
    
}
